#include "mtf"

mxf::mxf() {
	uchar i = 0;
	do {
		dict[i] = i;
	} while(++i);
}

void mxf::operator() (uchar *buf, unsigned long bufsize) {
	while(bufsize--) {
		*buf = (*this) (*buf);
		buf++;
	}
}

uchar mtf::operator() (uchar in) {
	register uchar ret = 0;
	while(dict[ret] != in) ret++;
	for(register uchar i = ret; i; i--) {
		dict[i] = dict[i - 1];
	}
	*dict = in;
	return ret;
}

uchar mff::operator() (uchar in) {
	register uchar ret = dict[in];
	for(register uchar i = in; i; i--) {
		dict[i] = dict[i - 1];
	}
	*dict = ret;
	return ret;
}

